package com.kpijavatraining.module.utils;

import java.io.IOException;
import java.lang.String;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
import com.kpijavatraining.module.User;
import com.kpijavatraining.module.io.ConsolePrinter;
import com.kpijavatraining.module.io.ConsoleReader;

public class Authorizer {

	private Checker checker;
	private User user;

	public Authorizer() throws ParserConfigurationException, SAXException, IOException{

		checker = new Checker();
	}

	 /**
	 * method registers the user and returns a flag of success of registration
	 * @return boolean - flag of success of registration
	 * @throws java.io.IOException
	 */
	public boolean authorization(String login , String password) throws IOException{

        if(checker.authenticationIs(login, password)){
            user = checker.getUser();
            return true;
        }
        return false;
	}	

	public User getUser(){
		return user;
	}

}
